<?php

class IndexAction extends Action{
    public function index(){
      $this->display();
    }

    public function reg(){
    	
    	  $this->display();
    	
    }
	
	public function reg2(){
    	
    	  $this->display();
    	
    }
    public function login(){
    	
    	  $this->display();
    	
    }
	
	public function doReg() {
		$user = D('User');
		if(md5($_POST['verify']) != $_SESSION['verify']) {
			$this->error('验证码错误！');
		}
		if($user->create()){
			$user->password = md5($user->password);
			$user->ctime = time();
			$user->etime = time();
			$user->status = 0;
			$user->type = 0;
			$user->groupid = 0;
			Load('extend'); //ip 加载函数库
			$user->eip = get_client_ip();
			if($user->add()){
					$this->assign("jumpUrl","__URL__/login");
			    $this->success("注册成功，请登录！");
				}else{
					$this->error('注册失败！');
				}
		}else{
			$this->error($user->getError());
		}
	}
	
	public function dologin(){
		$userModel = M('User');
		$user = $userModel->where('account="'.$_POST['account'].'" AND password="'.md5($_POST['password']).'"')->find();
		//验证码判断
	    if($_SESSION['verify'] != md5($_POST['verify'])) {   
				$this->error('验证码错误！');   
  		}else{
				if($user){
		    	$_SESSION['userInfo']['id'] =$user['id'];
					$_SESSION['userInfo']['account'] =$user['account'];
					$_SESSION['userInfo']['name'] =$user['name'];
					$_SESSION['userInfo']['type'] =$user['type'];
					$_SESSION['userInfo']['groupid'] =$user['groupid'];
					Load('extend'); //加载函数库
					$data['id'] = $user['id'];
					$data['eip'] = get_client_ip();
					$data['etime'] = time();
					$result = $userModel->save($data); // 新ip写入数据库
					$this->redirect('index/index');
				}else{
					
					$this->error('用户名或密码错误！');  
				}
		}
	}
	
	public function logout(){
		session_destroy();
		$this->redirect('index');	
	}
	
	public function yp(){
		$this->display();
	}
	
  public function verify(){
  	import("ORG.Util.Image");   
		Image::buildImageVerify();
  }

  public function resumelist(){
      $this->display();
  }

}
?>